From 00dd4b7674cdd2f5366122b2c5a2859cc34016fb Mon Sep 17 00:00:00 2001 From: Boris Egorov Date: Tue, 23 Feb 2016 23:44:54 +0600 Subject: [PATCH] Clarify third party subcommand failure error message Fixes #2378 --- src/bin/cargo.rs | 6 ++++-- tests/test_cargo_install.rs | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 350448df0..9011ca1fe 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -11,7 +11,7 @@ use std::fs; use std::path::PathBuf; use cargo::execute_main_without_stdin; -use cargo::util::{self, CliResult, lev_distance, Config, human, CargoResult}; +use cargo::util::{self, CliResult, lev_distance, Config, human, CargoResult, ChainError}; #[derive(RustcDecodable)] pub struct Flags { @@ -205,7 +205,9 @@ fn execute_subcommand(config: &Config, })) } }; - try!(util::process(&command).args(&args[1..]).exec()); + try!(util::process(&command).args(&args[1..]).exec().chain_error(|| { + human(format!("third party subcommand `{}` exited unsuccessfully", command_exe)) + })); Ok(()) } diff --git a/tests/test_cargo_install.rs b/tests/test_cargo_install.rs index db00ef614..2b54f940e 100644 --- a/tests/test_cargo_install.rs +++ b/tests/test_cargo_install.rs @@ -568,3 +568,25 @@ be sure to add `[..]` to your PATH to be able to run the installed binaries assert!(p.release_bin("foo").c_exists()); assert_that(cargo_home(), has_installed_exe("foo")); }); + +test!(reports_unsuccessful_subcommand_result { + Package::new("cargo-fail", "1.0.0") + .file("src/main.rs", r#" + fn main() { + panic!(); + } + "#) + .publish(); + assert_that(cargo_process("install").arg("cargo-fail"), + execs().with_status(0)); + assert_that(cargo_process("--list"), + execs().with_status(0).with_stdout_contains(" fail\n")); + assert_that(cargo_process("fail"), + execs().with_status(101).with_stderr_contains("\ +thread '
' panicked at 'explicit panic', [..] +").with_stderr_contains("\ +third party subcommand `cargo-fail[..]` exited unsuccessfully + +To learn more, run the command again with --verbose. +")); +}); -- 2.30.2